// Copyright (c) 2019 Presto Labs Pte. Ltd.
// Author: jaewon

#include "coin1/base/datetime_util.h"

#include <glog/logging.h>
#include <gtest/gtest.h>

TEST(DatetimeUtil, ParseISO8601String) {
  EXPECT_EQ(ParseISO8601String("2019-08-12T12:34:56"), 1565613296000000000LL);
  EXPECT_EQ(ParseISO8601String("2019-08-12T12:34:56."), std::nullopt);
  EXPECT_EQ(ParseISO8601String("2019-08-12T12:34:56.1"), 1565613296100000000LL);
  EXPECT_EQ(ParseISO8601String("2019-08-12T12:34:56.12"), 1565613296120000000LL);
  EXPECT_EQ(ParseISO8601String("2019-08-12T12:34:56.123"), 1565613296123000000LL);
  EXPECT_EQ(ParseISO8601String("2019-08-12T12:34:56.1234"), 1565613296123400000LL);
  EXPECT_EQ(ParseISO8601String("2019-08-12T12:34:56.12345"), 1565613296123450000LL);
  EXPECT_EQ(ParseISO8601String("2019-08-12T12:34:56.123456"), 1565613296123456000LL);
  EXPECT_EQ(ParseISO8601String("2019-08-12T12:34:56.1234567"), 1565613296123456700LL);
  EXPECT_EQ(ParseISO8601String("2019-08-12T12:34:56.12345678"), 1565613296123456780LL);
  EXPECT_EQ(ParseISO8601String("2019-08-12T12:34:56.123456789"), 1565613296123456789LL);
}
